import { Injectable } from '@angular/core'
import { Observable, of } from 'rxjs'

import {
  ReportService,
  IReportSettingParams,
  IReportConfigParams,
  IReportReleaseParams,
  IReportReleaseDownload,
  IReportReleaseDownloadPagination
} from './report.abstract.service'
import {
  IReportSetting,
  IReportSettingPagination,
  IReportConfig,
  IReportConfigPagination,
  IReportReleaseRecord,
  IReportReleaseRecordPagination
} from '@shared/interfaces/report'
import { EReportType, EReportStatus } from '@shared/enums/index'
import { HttpClient } from '@angular/common/http'
import { COMB_URL } from 'app/utils/contraints'
import { preProcessParams, encodeParams } from '@shared/decorators'

@Injectable()
export class ReportAlinterService implements ReportService {

  constructor(
    private http: HttpClient,
  ) { }

  // 获取报表设定信息列表
  getSettingList(params: IReportSettingParams): Observable<IReportSettingPagination> {
    // TODO:
    return of()
  }

  // 获取报表配置信息列表
  getConfigList(params: IReportConfigParams): Observable<IReportConfigPagination> {
    // TODO:
    return of()
  }

  // 获取已生成的报表记录列表
  @preProcessParams()
  @encodeParams()
  getReleaseList(params: IReportReleaseParams, str: string): Observable<IReportReleaseRecordPagination> {
    const url = `${COMB_URL}/camel/reports?${str}`
    return this.http.get<IReportReleaseRecordPagination>(url)
  }

  /** 下载报表 */
  downloadReport(key: string): Observable<IReportReleaseDownloadPagination> {
    const url = `${COMB_URL}/camel/reports/download?rptKey=${key}`
    return this.http.get<IReportReleaseDownloadPagination>(url)
  }
}
